import React from 'react';
import { observer } from 'mobx-react';
import TemplateManageStore from '../../stores/list/TemplateManageStore';
import { WeaDialog, WeaLocaleProvider } from 'ecCom';
import { Button } from 'antd';
import AdvancedSearchs from '../../components/list/AdvancedSearchs';
const getLabel = WeaLocaleProvider.getLabel;

export interface SetCustomConditionProps {
    templateManageStore:TemplateManageStore
}
@observer
export default class SetCustomCondition extends React.Component<SetCustomConditionProps, any> {
    render() {
        const {templateManageStore}=this.props;
        return (
            <div>
                <AdvancedSearchs form= {templateManageStore.conditionForm} conditioninfo={templateManageStore.conditionInfo}  />
            </div >
        )
    }
}

@observer
export class SetCustomConditionDialog extends React.Component<SetCustomConditionProps, any>{
    render() {
        const { templateManageStore} = this.props;
        const {iconInfo } =templateManageStore;
        const buttons = [<Button onClick={()=>{templateManageStore.visible_set_condition=false}}>{getLabel(309,"关闭")}</Button>,
        <Button type="primary" loading={templateManageStore.loading} onClick={templateManageStore.saveCustomCondition}>{getLabel(86,'保存')}</Button>]
        return (
            <WeaDialog
                className='wea-auth-modal cube-dialog'
                buttons={buttons}
                title={getLabel(83142, '查询条件定义', 'label')}
                iconBgcolor={iconInfo.iconBg || "#96358a"}
                icon={iconInfo.icon ||'icon-coms-ModelingEngine'}
                iconFontColor={iconInfo.iconColor || "#fff"}
                visible={templateManageStore.visible_set_condition}
                style={{ width: 1024, height: 600 }}
                hasScroll={true}
                onCancel={()=>{templateManageStore.visible_set_condition=false}}
            >
                <SetCustomCondition templateManageStore={templateManageStore} />
            </WeaDialog >
        )
    }
}